package com.fortune.controller.app;

import com.fortune.dal.dao.FinancialProductDAO;
import com.fortune.dal.model.FinancialProduct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

@RestController
@RequestMapping("financialproduct")
public class FinancialProductController{

    @Autowired
    private FinancialProductDAO financialProductDAO;


    @RequestMapping(value = "", method = RequestMethod.GET)
    public ModelAndView indexOfAll() throws Exception {
        ModelAndView mv = new ModelAndView("test");
        List<FinancialProduct> financialProduct = financialProductDAO.queryByModel(new FinancialProduct());
        mv.addObject("financialProduct", financialProduct);
        return mv;
    }

//    @RequestMapping(value = "/list", method = RequestMethod.GET)
//    public List<Map<String,Object>> list(@ModelAttribute FinancialProduct financialProduct) throws BusinessException {
//        List<Map<String,Object>> list = Lists.newArrayList();
//        try {
//            List<FinancialProduct> lists = financialProductDAO.queryByModel(financialProduct);
//            if(ListUtils.isNotEmpty(lists)){
//                for(FinancialProduct fps : lists){
//                    Map<String,Object> map = MapUtils.parseMap(fps);
//                    list.add(map);
//                }
//            }
//        } catch (Exception ex) {
//            logger.error("",ex);
//            return Lists.newArrayList() ;
//        }
//
//        return list;
//    }


}
